﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using TL_Cloud.Core.Entities;

namespace TL_Cloud.Models.BookShop
{
    public partial class Base_User : BaseEntity
    {
        /// <summary>
        /// 用户编号
        /// </summary>
        public string UserId { get; set; }
        /// <summary>
        /// 用户登录账号
        /// </summary>
        public string UserCode { get; set; }
        /// <summary>
        /// 用户名称
        /// </summary>
        public string UserName { get; set; }
        public int? Role { get; set; }
        public string Password { get; set; }
        public string Telephone { get; set; }
        public string Email { get; set; }
        /// <summary>
        /// 用户信息编号 ,对应的是老师的编号 和学生的编号
        /// </summary>
        public string UserInfoId { get; set; }
        public string HeadIcon { get; set; }



        public override void Create(string userId, string userName)
        {
            this.UserId = Guid.NewGuid().ToString();
            this.CreateDate = DateTime.Now; 
        }
       
        public override void Mapping(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Base_User>(entity =>
            {
                entity.HasKey(e => e.UserId);

                entity.ToTable("Base_User");

                entity.Property(e => e.UserId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .ValueGeneratedNever();

                entity.Property(e => e.CreateDate).HasColumnType("datetime");

                entity.Property(e => e.Email)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Password)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Telephone)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.UserCode)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.UserInfoId)
                    .HasMaxLength(50)
                    .IsUnicode(false);
            });
        }
    }
}
